#!/bin/bash
# set -e
# 0 表示异常
# runner
function getDisks(){
    VALUE=`egrep -v 'major|^$|dm-|[0-9]$' /proc/partitions | awk '
    BEGIN{ORS="";n=0}
    {
        print ""$4" "

    }
    '`
    echo ${VALUE}
}

echo "# TYPE node_disk_smartctl_health gauge"     
for disk in $(getDisks)
do
    VALUE=`/usr/sbin/smartctl -H /dev/${disk} | grep -c "PASSED\|OK\|md0"` 
    if [ ! $VALUE ]; then
        echo "node_disk_smartctl_health{device=\"${disk}\"} 0"
    else
        echo "node_disk_smartctl_health{device=\"${disk}\"} ${VALUE}"
    fi 
done

